package com.zsr.xmall.search.controller;

import com.zsr.common.vo.search.SearchParam;
import com.zsr.common.vo.search.SearchResult;
import com.zsr.xmall.search.service.impl.MallSearchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zhousiren
 * @description
 * @date 2022/7/4 21:38
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchServiceImpl mallSearchService;


    /**
     * 查询页面
     */
    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model, HttpServletRequest request) {
        //用于取消面包屑之后 移除该属性
        param.set_queryString(request.getQueryString());
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result", result);
        return "list";
    }
}
